import 'package:flutter/material.dart';
import 'package:hzcloud_flt/feature/views/home.menus.view.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class ServiceWorkBench extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _ServiceWorkBenchState();
  }
}

class _ServiceWorkBenchState extends State<ServiceWorkBench> {
  @override
  Widget build(BuildContext context) {
// TODO: implement build
    return Scaffold(
      appBar: AppBar(title: Text('服务功能'),),
      body: CustomScrollView(
        slivers: [
          ServiceWorkBenchHeader(title: "常用功能"),
          SliverGrid(
            delegate:
            SliverChildBuilderDelegate((BuildContext context, int index) {
              return MenuItem();
            }, childCount: 7),
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 5,
            ),
          ),
          ServiceWorkBenchHeader(title: "全部功能"),
          SliverGrid(
            delegate:
            SliverChildBuilderDelegate((BuildContext context, int index) {
              return MenuItem(onPress: (){
                Navigator.pop(context);
              },);
            }, childCount: 10),
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 5,
            ),
          )
        ],
      ),
    );
  }
}

class ServiceWorkBenchHeader extends StatelessWidget {
  final String title;

  const ServiceWorkBenchHeader({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return SliverToBoxAdapter(
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 15),
        alignment: Alignment.centerLeft,
        height: 45,
        child: Text(
          title,
          style: TextStyle(
            fontSize: 16,
            color: Colors.black,
            fontWeight: FontWeight.w500,
          ),
        ),
      ),
    );
  }
}